<?php

namespace app\admin\Lib;
use think\Controller;
class Tree{
	//菜单列表
Static public function findmenu($menu,$html='|--', $uid = 0 , $level=0)
	{
	$arr=array();
	foreach ($menu as $v){
		if ($v['uid']==$uid){
			$v['level']=$level + 1;
			$v['html']=str_repeat($html, $level);
			$arr[]=$v;
			$arr=array_merge($arr,self::findmenu($menu,$html,$v['id'],$level + 1));
		}
	}
		return $arr;
	}

			//无限级分类
			Static public function findnews($cate , $mid = 0){
				$arr = array();
				foreach ($cate as $v) {
					if ($v['uid'] == $mid) {
						$v['child'] = self::findnews($cate,$v['id']);
						$arr[] = $v;
				}
			}
				return $arr;

			}
	//通用查询车辆上级名称
	Static public function nextlevel($menu,$uid='0',$html="-->",$level =1){
		$arr=array();
		foreach ($menu as $v){
			if ($v['id']==$uid){
					$v['level']=$level+1 ;
					$v['html']=str_repeat($html, $level);
				$arr[]=$v;
				$arr=array_merge($arr,self::nextlevel($menu,$v['uid'],$html,$level ));
			}
		}
			return $arr;
	}

	}
